package com.leetcode.weekly.contest.no286th;

/**
 * @author 覃国强
 * @date 2022-03-27 10:56
 */
public class A02_美化数组的最少删除数 {


  static
  class Solution {
    public int minDeletion(int[] nums) {
      if (nums == null || nums.length == 0) {
        return 0;
      }

      int answer = 0;
      int left = 0;
      int right;
      while (left < nums.length) {
        right = left + 1;
        while (right < nums.length && nums[left] == nums[right]) {
          ++answer;
          ++right;
        }
        if (right == nums.length) {
          ++answer;
        }
        left = right + 1;
      }

      return answer;
    }
  }

}
